﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace AutoChess
{
    public abstract class BaseRenderer : MonoBehaviour,IVisualRenderer<BaseUnit,BaseRenderer>
    {
        protected BaseUnit ownerUnit;

        private void Awake()
        {
            OnRendererBorn();
        }
        private void Update()
        {
            OnRendererUpdate();
        }
        private void OnDestroy()
        {
            OnRendererDestroy();
        }

        #region 生命周期

        protected virtual void OnRendererBorn() { }
        protected virtual void OnRendererDestroy() { }
        protected virtual void OnRendererUpdate() { }

        public abstract void OnConnect(BaseUnit data);
        public virtual void OnDisconnect()
        {
            this.ownerUnit = null;
            transform.SetUnused(false, GameConst.AC_UNUSED);
        }
        public abstract void RefreshRenderer();
        #endregion
    }
}
